<template>
  <cus-form :nodes="nodes" ref="formRef"></cus-form>
</template>

<script lang="ts">
import { ref, onMounted } from 'vue'
import axios from 'axios';
import { AxResponse } from '@/core/axios';
import { ElMessage } from 'element-plus';
import { emitter } from '$';
export default {
  props: {
    data: {
      type: Object,
      default: () => {}
    },
    addType: {
      type: String,
      default: ''
    },
    idx: {
      type: Number,
      default: ''
    }
  },
  setup(props, { emit }) {
    let formRef = ref();
    let nodes: any = ref([
      { label: '名称', type: 'input', key: 'title', rule: { required: true, message: '请输入名称' }},
    ]);
    const save = (resolve, reject) => {
      formRef.value.validate(valid => {
        if(valid) {
          let data = {
            ...valid,
            moduleId: props.data.moduleId,
            sortNum: props.idx + 2,
            type: 1,
            cssType : 1,
          }
          resolve(data);
          ElMessage.success('新建标题成功~！');
        }else {
          reject()
        }
      })
    }
    return { nodes, save, formRef }
  }
}
</script>

<style lang="scss" scoped>

</style>